home *** CD-ROM | disk | FTP | other *** search
Text File | 1993-06-06 | 32.9 KB | 1,296 lines |
- diff --context --recursive --new-file bsd-sh/Makefile sh03/Makefile
- *** bsd-sh/Makefile Fri Feb 19 08:41:42 1993
- --- sh03/Makefile Wed Jun 2 01:22:16 1993
- ***************
- *** 1,46 ****
- # %W% (Berkeley) %G%
-
- PROG= sh
- ! SRCS= builtins.c cd.c dirent.c echo.c error.c eval.c exec.c expand.c \
- input.c jobs.c mail.c main.c memalloc.c miscbltin.c \
- mystring.c nodes.c options.c parser.c redir.c show.c signames.c \
- syntax.c trap.c output.c var.c
- ! OBJS+= init.o
- ! CFLAGS+=-DSHELL -I. -I${.CURDIR}
- ! .PATH: ${.CURDIR}/bltin
- ! CLEANFILES+=\
- ! builtins.c builtins.h init.c mkinit mknodes mksignames mksyntax \
- ! nodes.c nodes.h signames.c signames.h syntax.c syntax.h token.def
-
- ! .depend parser.o: token.def
- token.def: mktokens
- ! sh ${.CURDIR}/mktokens
-
- ! builtins.h builtins.c: ${.CURDIR}/mkbuiltins ${.CURDIR}/builtins
- ! cd ${.CURDIR}; sh mkbuiltins
-
- ! init.c: mkinit ${SRCS}
- ! ./mkinit '${CC} -c ${CFLAGS} init.c' ${.ALLSRC}
-
- ! mkinit: ${.CURDIR}/mkinit.c
- ! ${CC} ${CFLAGS} ${.CURDIR}/mkinit.c -o $@
-
- ! nodes.c nodes.h: mknodes ${.CURDIR}/nodetypes ${.CURDIR}/nodes.c.pat
- ! ./mknodes ${.CURDIR}/nodetypes ${.CURDIR}/nodes.c.pat
-
- ! mknodes: ${.CURDIR}/mknodes.c
- ! ${CC} ${CFLAGS} ${.CURDIR}/mknodes.c -o $@
-
- signames.c signames.h: mksignames
- ./mksignames
-
- ! mksignames: ${.CURDIR}/mksignames.c
- ! ${CC} ${CFLAGS} ${.CURDIR}/mksignames.c -o $@
-
- syntax.c syntax.h: mksyntax
- ./mksyntax
-
- ! mksyntax: ${.CURDIR}/mksyntax.c ${.CURDIR}/parser.h
- ! ${CC} ${CFLAGS} ${.CURDIR}/mksyntax.c -o $@
-
- ! .include <bsd.prog.mk>
- --- 1,123 ----
- # %W% (Berkeley) %G%
-
- + # Makefile for Kenneth Almquist's Bourne Shell for Atari ST/MiNT
- + # hohmuth 21 Mar 1993
- + #
- + # This Makefile needs GNU Make.
- +
- PROG= sh
- ! SRCS= builtins.c cd.c dirent.c bltin/echo.c error.c eval.c exec.c expand.c \
- input.c jobs.c mail.c main.c memalloc.c miscbltin.c \
- mystring.c nodes.c options.c parser.c redir.c show.c signames.c \
- syntax.c trap.c output.c var.c
- ! OBJS= $(patsubst %.c,%.o,$(SRCS)) init.o
- !
- !
- ! CC= gcc $(MODEL) -O2 -fomit-frame-pointer -fstrength-reduce
- ! CFLAGS= -I. -Ibltin $(DEFS)
- !
- ! MODEL= -mbaserel
- ! DEFS= -DDOSFS -DSHELL -DENOTDIR=EPATH
- !
- ! POSTPROC1= toglclr -fload -fram -frun
- !
- ! all: $(PROG)
- !
- ! $(PROG): $(OBJS)
- ! $(CC) -o $@ $^ -lbiio
- ! ifdef POSTPROC1
- ! $(POSTPROC1) $@
- ! endif
- !
- ! %.o: %.c
- ! $(CC) $(CFLAGS) -o $@ -c $<
-
- ! parser.o: token.def
- token.def: mktokens
- ! /bin/sh mktokens
-
- ! builtins.h builtins.c: mkbuiltins builtins
- ! /bin/sh mkbuiltins
-
- ! init.o: mkinit ${SRCS}
- ! ./mkinit '${CC} -c ${CFLAGS} init.c' ${SRCS}
-
- ! mkinit: mkinit.c
- ! ${CC} ${CFLAGS} mkinit.c -o $@
-
- ! nodes.c nodes.h: mknodes nodetypes nodes.c.pat
- ! ./mknodes nodetypes nodes.c.pat
-
- ! mknodes: mknodes.c
- ! ${CC} ${CFLAGS} mknodes.c -o $@
-
- signames.c signames.h: mksignames
- ./mksignames
-
- ! mksignames: mksignames.c
- ! ${CC} ${CFLAGS} mksignames.c -o $@
-
- syntax.c syntax.h: mksyntax
- ./mksyntax
-
- ! mksyntax: mksyntax.c parser.h
- ! ${CC} ${CFLAGS} mksyntax.c -o $@
-
- ! .PHONY: clean
- ! clean:
- ! -rm -f ${OBJS}
- !
- ! .PHONY: realclean
- ! realclean: clean
- ! -rm -f mksyntax syntax.c syntax.h
- ! -rm -f mksignames signames.c signames.h
- ! -rm -f mknodes nodes.c nodes.h
- ! -rm -f mkinit init.c
- ! -rm -f builtins.c builtins.h
- ! -rm -f token.def
- ! -rm -f ${PROG}
- !
- ! ### dependencies
- !
- ! builtins: ;
- !
- ! builtins.o : builtins.c shell.h builtins.h
- ! cd.o : cd.c shell.h var.h nodes.h jobs.h options.h output.h memalloc.h error.h \
- ! mystring.h
- ! dirent.o : dirent.c shell.h
- ! error.o : error.c shell.h main.h options.h output.h error.h
- ! mksyntax.o : mksyntax.c parser.h
- ! eval.o : eval.c shell.h nodes.h syntax.h expand.h parser.h jobs.h eval.h builtins.h \
- ! options.h exec.h redir.h input.h output.h trap.h var.h memalloc.h error.h mystring.h
- ! exec.o : exec.c shell.h main.h nodes.h parser.h redir.h eval.h exec.h builtins.h \
- ! var.h options.h input.h output.h syntax.h memalloc.h error.h init.h mystring.h
- ! expand.o : expand.c shell.h main.h nodes.h eval.h expand.h syntax.h parser.h \
- ! jobs.h options.h var.h input.h output.h memalloc.h error.h mystring.h
- ! input.o : input.c shell.h syntax.h input.h output.h memalloc.h error.h
- ! mksignames.o : mksignames.c
- ! jobs.o : jobs.c shell.h main.h parser.h nodes.h jobs.h \
- ! options.h trap.h signames.h syntax.h input.h output.h memalloc.h error.h mystring.h
- ! mail.o : mail.c shell.h exec.h var.h output.h memalloc.h error.h
- ! main.o : main.c shell.h main.h mail.h options.h output.h parser.h nodes.h eval.h \
- ! jobs.h input.h trap.h memalloc.h error.h init.h mystring.h
- ! memalloc.o : memalloc.c shell.h output.h memalloc.h error.h machdep.h mystring.h
- ! miscbltin.o : miscbltin.c shell.h options.h var.h output.h memalloc.h error.h \
- ! mystring.h
- ! mystring.o : mystring.c shell.h syntax.h error.h mystring.h
- ! nodes.o : nodes.c shell.h nodes.h memalloc.h machdep.h mystring.h
- ! options.o : options.c shell.h options.h nodes.h eval.h jobs.h input.h output.h \
- ! trap.h var.h memalloc.h error.h mystring.h
- ! parser.o : parser.c shell.h parser.h nodes.h expand.h redir.h syntax.h options.h \
- ! input.h output.h var.h error.h memalloc.h mystring.h token.def
- ! redir.o : redir.c shell.h nodes.h jobs.h expand.h redir.h output.h memalloc.h \
- ! error.h
- ! show.o : show.c shell.h parser.h nodes.h mystring.h
- ! signames.o : signames.c shell.h
- ! syntax.o : syntax.c shell.h syntax.h
- ! trap.o : trap.c shell.h main.h nodes.h eval.h jobs.h options.h syntax.h signames.h \
- ! output.h memalloc.h error.h trap.h mystring.h
- ! output.o : output.c shell.h syntax.h output.h memalloc.h error.h
- ! var.o : var.c shell.h output.h expand.h nodes.h eval.h exec.h syntax.h options.h \
- ! mail.h var.h memalloc.h error.h mystring.h
- ! init.o : shell.h mystring.h eval.h input.h error.h options.h redir.h \
- ! signames.h trap.h output.h memalloc.h var.h
- diff --context --recursive --new-file bsd-sh/builtins sh03/builtins
- *** bsd-sh/builtins Fri Feb 19 08:41:56 1993
- --- sh03/builtins Sat May 22 00:41:42 1993
- ***************
- *** 61,66 ****
- --- 61,67 ----
- exitcmd exit
- exportcmd export readonly
- #exprcmd expr test [
- + falsecmd false
- fgcmd -j fg
- getoptscmd getopts
- hashcmd hash
- diff --context --recursive --new-file bsd-sh/cd.c sh03/cd.c
- *** bsd-sh/cd.c Fri Feb 19 08:42:02 1993
- --- sh03/cd.c Sun Mar 21 14:49:26 1993
- ***************
- *** 187,193 ****
- i += strlen(cdcomppath);
- p = stalloc(i);
- if (readlink(symlink, p, (int)statb.st_size) < 0) {
- ! error("readlink %s failed", stackblock());
- }
- if (cdcomppath != NULL) {
- p[(int)statb.st_size] = '/';
- --- 187,193 ----
- i += strlen(cdcomppath);
- p = stalloc(i);
- if (readlink(symlink, p, (int)statb.st_size) < 0) {
- ! error("readlink %s failed", symlink);
- }
- if (cdcomppath != NULL) {
- p[(int)statb.st_size] = '/';
- ***************
- *** 343,349 ****
- close(pip[1]);
- }
- execl("/bin/pwd", "pwd", (char *)0);
- ! error("Cannot exec /bin/pwd");
- }
- close(pip[1]);
- pip[1] = -1;
- --- 343,350 ----
- close(pip[1]);
- }
- execl("/bin/pwd", "pwd", (char *)0);
- ! /* error("Cannot exec /bin/pwd"); */
- ! exitshell(-1);
- }
- close(pip[1]);
- pip[1] = -1;
- ***************
- *** 358,366 ****
- --- 359,374 ----
- status = waitforjob(jp);
- if (status != 0)
- error((char *)0);
- + #ifdef __MINT__
- + if (i < 0 || p == buf || !( p[-1] == '\n' || p[-1] == '\r'))
- + error("pwd command failed");
- + while (--p, (*p == '\n' || *p == '\r'))
- + *p = 0;
- + #else
- if (i < 0 || p == buf || p[-1] != '\n')
- error("pwd command failed");
- p[-1] = '\0';
- + #endif
- curdir = savestr(buf);
- INTON;
- }
- diff --context --recursive --new-file bsd-sh/error.c sh03/error.c
- *** bsd-sh/error.c Fri Feb 19 08:42:26 1993
- --- sh03/error.c Sun Mar 21 14:56:00 1993
- ***************
- *** 179,195 ****
- STATIC const struct errname errormsg[] = {
- EINTR, ALL, "interrupted",
- EACCES, ALL, "permission denied",
- EIO, ALL, "I/O error",
- ENOENT, E_OPEN, "no such file",
- ENOENT, E_CREAT, "directory nonexistent",
- ENOENT, E_EXEC, "not found",
- ENOTDIR, E_OPEN, "no such file",
- ENOTDIR, E_CREAT, "directory nonexistent",
- ENOTDIR, E_EXEC, "not found",
- EISDIR, ALL, "is a directory",
- ! /* EMFILE, ALL, "too many open files", */
- ENFILE, ALL, "file table overflow",
- ENOSPC, ALL, "file system full",
- #ifdef EDQUOT
- EDQUOT, ALL, "disk quota exceeded",
- #endif
- --- 179,205 ----
- STATIC const struct errname errormsg[] = {
- EINTR, ALL, "interrupted",
- EACCES, ALL, "permission denied",
- + #ifdef EIO
- EIO, ALL, "I/O error",
- + #endif
- ENOENT, E_OPEN, "no such file",
- ENOENT, E_CREAT, "directory nonexistent",
- ENOENT, E_EXEC, "not found",
- ENOTDIR, E_OPEN, "no such file",
- ENOTDIR, E_CREAT, "directory nonexistent",
- ENOTDIR, E_EXEC, "not found",
- + #ifdef EISDIR
- EISDIR, ALL, "is a directory",
- ! #endif
- ! #ifdef EMFILE
- ! EMFILE, ALL, "too many open files",
- ! #endif
- ! #ifdef ENFILE
- ENFILE, ALL, "file table overflow",
- + #endif
- + #ifdef ENOSPC
- ENOSPC, ALL, "file system full",
- + #endif
- #ifdef EDQUOT
- EDQUOT, ALL, "disk quota exceeded",
- #endif
- ***************
- *** 198,204 ****
- --- 208,216 ----
- #endif
- ENXIO, ALL, "no such device or address",
- EROFS, ALL, "read-only file system",
- + #ifdef ETXTBSY
- ETXTBSY, ALL, "text busy",
- + #endif
- #ifdef SYSV
- EAGAIN, E_EXEC, "not enough memory",
- #endif
- ***************
- *** 221,227 ****
- --- 233,241 ----
- #ifdef ELOOP
- ELOOP, ALL, "symbolic link loop",
- #endif
- + #ifdef E2BIG
- E2BIG, E_EXEC, "argument list too long",
- + #endif
- #ifdef ELIBACC
- ELIBACC, E_EXEC, "shared library missing",
- #endif
- ***************
- *** 240,245 ****
- --- 254,263 ----
- struct errname const *ep;
- static char buf[12];
-
- + #ifdef __MINT__
- + if (e < 32)
- + return "I/O error";
- + #endif
- for (ep = errormsg ; ep->errcode ; ep++) {
- if (ep->errcode == e && (ep->action & action) != 0)
- return ep->msg;
- diff --context --recursive --new-file bsd-sh/error.h sh03/error.h
- *** bsd-sh/error.h Fri Feb 19 08:42:32 1993
- --- sh03/error.h Wed Feb 17 04:27:32 1993
- ***************
- *** 108,113 ****
- --- 108,115 ----
- */
-
- #ifdef BSD
- + #ifndef __MINT__
- #define setjmp(jmploc) _setjmp(jmploc)
- #define longjmp(jmploc, val) _longjmp(jmploc, val)
- #endif
- + #endif
- diff --context --recursive --new-file bsd-sh/eval.c sh03/eval.c
- *** bsd-sh/eval.c Fri Feb 19 08:42:40 1993
- --- sh03/eval.c Sat May 22 00:41:46 1993
- ***************
- *** 899,904 ****
- --- 899,907 ----
- return ret;
- }
-
- + falsecmd(argc, argv) char **argv; {
- + return 1;
- + }
-
- truecmd(argc, argv) char **argv; {
- return 0;
- diff --context --recursive --new-file bsd-sh/exec.c sh03/exec.c
- *** bsd-sh/exec.c Fri Feb 19 08:42:56 1993
- --- sh03/exec.c Wed Feb 17 06:13:50 1993
- ***************
- *** 69,74 ****
- --- 69,80 ----
- #include <fcntl.h>
- #include <errno.h>
-
- + #ifdef __MINT__
- + /* Defines order in which to look for executable program suffixes */
- + static const char *const suffixes[] = {
- + "", ".ttp", ".tos", ".prg", 0
- + };
- + #endif
-
- #define CMDTABLESIZE 31 /* should be prime */
- #define ARB 1 /* actual size determined at run time */
- ***************
- *** 150,164 ****
- do {
- execve(cmd, argv, envp);
- } while (errno == EINTR);
- ! #else
- execve(cmd, argv, envp);
- ! #endif
- e = errno;
- if (e == ENOEXEC) {
- initshellproc();
- setinputfile(cmd, 0);
- commandname = arg0 = savestr(argv[0]);
- ! #ifndef BSD
- pgetc(); pungetc(); /* fill up input buffer */
- p = parsenextc;
- if (parsenleft > 2 && p[0] == '#' && p[1] == '!') {
- --- 156,187 ----
- do {
- execve(cmd, argv, envp);
- } while (errno == EINTR);
- ! #else /* !SYSV */
- ! #ifdef __MINT__
- ! {
- ! const char *const *suffix;
- ! long len = strlen(cmd);
- !
- ! char *xcmd = alloca(len+5);
- ! strcpy(xcmd,cmd);
- !
- ! for (suffix = suffixes; *suffix; suffix++) {
- ! strcpy(xcmd + len, *suffix);
- ! execve(xcmd, argv, envp);
- !
- ! if (errno == ENOEXEC) break;
- ! }
- ! }
- ! #else /* !__MINT__, !SYSV */
- execve(cmd, argv, envp);
- ! #endif /* !__MINT__ */
- ! #endif /* !SYSV */
- e = errno;
- if (e == ENOEXEC) {
- initshellproc();
- setinputfile(cmd, 0);
- commandname = arg0 = savestr(argv[0]);
- ! #if defined(__MINT__) || !defined(BSD)
- pgetc(); pungetc(); /* fill up input buffer */
- p = parsenextc;
- if (parsenleft > 2 && p[0] == '#' && p[1] == '!') {
- ***************
- *** 174,180 ****
- }
-
-
- ! #ifndef BSD
- /*
- * Execute an interpreter introduced by "#!", for systems where this
- * feature has not been built into the kernel. If the interpreter is
- --- 197,203 ----
- }
-
-
- ! #if defined(__MINT__) || !defined(BSD)
- /*
- * Execute an interpreter introduced by "#!", for systems where this
- * feature has not been built into the kernel. If the interpreter is
- ***************
- *** 212,223 ****
- goto bad;
- if ((c = *inp++) == '\n')
- break;
- if (ap == &newargs[NEWARGS])
- bad: error("Bad #! line");
- STARTSTACKSTR(outp);
- do {
- STPUTC(c, outp);
- ! } while (--n >= 0 && (c = *inp++) != ' ' && c != '\t' && c != '\n');
- STPUTC('\0', outp);
- n++, inp--;
- *ap++ = grabstackstr(outp);
- --- 235,255 ----
- goto bad;
- if ((c = *inp++) == '\n')
- break;
- + #ifdef __MINT__
- + if (c == '\r')
- + break;
- + #endif
- if (ap == &newargs[NEWARGS])
- bad: error("Bad #! line");
- STARTSTACKSTR(outp);
- do {
- STPUTC(c, outp);
- ! }
- ! while (--n >= 0 && (c = *inp++) != ' ' && c != '\t'
- ! #ifdef __MINT__
- ! && c != '\r'
- ! #endif
- ! && c != '\n');
- STPUTC('\0', outp);
- n++, inp--;
- *ap++ = grabstackstr(outp);
- ***************
- *** 459,473 ****
- TRACE(("searchexec \"%s\": no change\n", name));
- goto success;
- }
- while (stat(fullname, &statb) < 0) {
- ! #ifdef SYSV
- if (errno == EINTR)
- continue;
- ! #endif
- if (errno != ENOENT && errno != ENOTDIR)
- e = errno;
- goto loop;
- }
- e = EACCES; /* if we fail, this will be the error */
- if ((statb.st_mode & S_IFMT) != S_IFREG)
- goto loop;
- --- 491,525 ----
- TRACE(("searchexec \"%s\": no change\n", name));
- goto success;
- }
- + #ifdef __MINT__
- + {
- + const char *const *suffix;
- + long len = strlen(fullname);
- +
- + char *xcmd = alloca(len+5);
- + strcpy(xcmd,fullname);
- +
- + for (suffix = suffixes; *suffix; suffix++) {
- + strcpy(xcmd + len, *suffix);
- + if (stat(xcmd, &statb) >= 0)
- + break;
- + }
- +
- + if (*suffix == 0)
- + /* All suffixes tried to no avail */
- + goto loop;
- + }
- + #else /* !__MINT__*/
- while (stat(fullname, &statb) < 0) {
- ! # ifdef SYSV
- if (errno == EINTR)
- continue;
- ! # endif
- if (errno != ENOENT && errno != ENOTDIR)
- e = errno;
- goto loop;
- }
- + #endif /* !__MINT__ */
- e = EACCES; /* if we fail, this will be the error */
- if ((statb.st_mode & S_IFMT) != S_IFREG)
- goto loop;
- diff --context --recursive --new-file bsd-sh/expand.c sh03/expand.c
- *** bsd-sh/expand.c Fri Feb 19 08:43:16 1993
- --- sh03/expand.c Sat May 22 00:44:06 1993
- ***************
- *** 286,298 ****
- --- 286,306 ----
- in.nleft = i - 1;
- }
- lastc = *p++;
- + #ifdef __MINT__
- + if (lastc != '\0' && lastc != '\r') {
- + #else
- if (lastc != '\0') {
- + #endif
- if (full && syntax[lastc] == CCTL)
- STPUTC(CTLESC, dest);
- STPUTC(lastc, dest);
- }
- }
- + #ifdef __MINT__
- + if (lastc == '\n' || lastc == '\r') {
- + #else
- if (lastc == '\n') {
- + #endif
- STUNPUTC(dest);
- }
- if (in.fd >= 0)
- ***************
- *** 300,306 ****
- if (in.buf)
- ckfree(in.buf);
- if (in.jp)
- ! waitforjob(in.jp);
- if (quoted == 0)
- recordregion(startloc, dest - stackblock(), 0);
- TRACE(("evalbackq: size=%d: \"%.*s\"\n",
- --- 308,314 ----
- if (in.buf)
- ckfree(in.buf);
- if (in.jp)
- ! exitstatus = waitforjob(in.jp);
- if (quoted == 0)
- recordregion(startloc, dest - stackblock(), 0);
- TRACE(("evalbackq: size=%d: \"%.*s\"\n",
- ***************
- *** 499,505 ****
- case '*':
- sep = ' ';
- allargs:
- ! syntax = quoted? DQSYNTAX : BASESYNTAX;
- for (ap = shellparam.p ; (p = *ap++) != NULL ; ) {
- /* should insert CTLESC characters */
- while (*p) {
- --- 507,515 ----
- case '*':
- sep = ' ';
- allargs:
- ! /* Only emit CTLESC if we will do further processing,
- ! i.e. if allow_split is set. */
- ! syntax = quoted && allow_split ? DQSYNTAX : BASESYNTAX;
- for (ap = shellparam.p ; (p = *ap++) != NULL ; ) {
- /* should insert CTLESC characters */
- while (*p) {
- ***************
- *** 514,520 ****
- case '0':
- p = arg0;
- string:
- ! syntax = quoted? DQSYNTAX : BASESYNTAX;
- while (*p) {
- if (syntax[*p] == CCTL)
- STPUTC(CTLESC, expdest);
- --- 524,532 ----
- case '0':
- p = arg0;
- string:
- ! /* Only emit CTLESC if we will do further processing,
- ! i.e. if allow_split is set. */
- ! syntax = quoted && allow_split ? DQSYNTAX : BASESYNTAX;
- while (*p) {
- if (syntax[*p] == CCTL)
- STPUTC(CTLESC, expdest);
- ***************
- *** 1095,1101 ****
- argbackq = pattern->narg.backquote;
- STARTSTACKSTR(expdest);
- ifslastp = NULL;
- ! argstr(pattern->narg.text, 0);
- STPUTC('\0', expdest);
- p = grabstackstr(expdest);
- result = patmatch(p, val);
- --- 1107,1115 ----
- argbackq = pattern->narg.backquote;
- STARTSTACKSTR(expdest);
- ifslastp = NULL;
- ! /* Preserve any CTLESC characters inserted previously, so that
- ! we won't expand reg exps which are inside strings. */
- ! argstr(pattern->narg.text, 1);
- STPUTC('\0', expdest);
- p = grabstackstr(expdest);
- result = patmatch(p, val);
- diff --context --recursive --new-file bsd-sh/input.c sh03/input.c
- *** bsd-sh/input.c Fri Feb 19 08:43:34 1993
- --- sh03/input.c Sun Mar 21 15:15:42 1993
- ***************
- *** 181,200 ****
- --- 181,211 ----
- p = parsenextc = parsefile->buf;
- i = read(parsefile->fd, p, BUFSIZ);
- if (i <= 0) {
- + #ifndef __MINT__
- if (i < 0) {
- + #endif
- if (errno == EINTR)
- goto retry;
- + #ifndef __MINT__
- if (parsefile->fd == 0 && errno == EWOULDBLOCK) {
- int flags = fcntl(0, F_GETFL, 0);
- if (flags >= 0 && flags & O_NONBLOCK) {
- flags &=~ O_NONBLOCK;
- + #else
- + if (parsefile->fd == 0 && i == 0) {
- + int flags = fcntl(0, F_GETFL, 0);
- + if (flags >= 0 && flags & O_NDELAY) {
- + flags &=~ O_NDELAY;
- + #endif
- if (fcntl(0, F_SETFL, flags) >= 0) {
- out2str("sh: turning off NDELAY mode\n");
- goto retry;
- }
- }
- }
- + #ifndef __MINT__
- }
- + #endif
- parsenleft = EOF_NLEFT;
- return PEOF;
- }
- ***************
- *** 202,207 ****
- --- 213,224 ----
-
- /* delete nul characters */
- for (;;) {
- + #ifdef __MINT__
- + if (*p == '\r') {
- + p++;
- + break;
- + }
- + #endif
- if (*p++ == '\0')
- break;
- if (--i <= 0)
- ***************
- *** 209,215 ****
- --- 226,236 ----
- }
- q = p - 1;
- while (--i > 0) {
- + #ifdef __MINT__
- + if (*p != '\0' && *p != '\r')
- + #else
- if (*p != '\0')
- + #endif
- *q++ = *p;
- p++;
- }
- diff --context --recursive --new-file bsd-sh/jobs.c sh03/jobs.c
- *** bsd-sh/jobs.c Fri Feb 19 08:43:54 1993
- --- sh03/jobs.c Sat May 22 00:44:12 1993
- ***************
- *** 56,61 ****
- --- 56,62 ----
- #include "memalloc.h"
- #include "error.h"
- #include "mystring.h"
- + #include "redir.h"
- #include <fcntl.h>
- #include <signal.h>
- #include <errno.h>
- ***************
- *** 509,514 ****
- --- 510,518 ----
- {
- int pid;
- int pgrp;
- + #ifdef __MINT__
- + int fd;
- + #endif
-
- TRACE(("forkshell(%%%d, 0x%x, %d) called\n", jp - jobtab, (int)n, mode));
- INTOFF;
- ***************
- *** 550,569 ****
- } else if (mode == FORK_BG) {
- ignoresig(SIGINT);
- ignoresig(SIGQUIT);
- ! if (jp == NULL || jp->nprocs == 0) {
- close(0);
- if (open("/dev/null", O_RDONLY) != 0)
- error("Can't open /dev/null");
- }
- }
- #else
- if (mode == FORK_BG) {
- ignoresig(SIGINT);
- ignoresig(SIGQUIT);
- ! if (jp == NULL || jp->nprocs == 0) {
- close(0);
- if (open("/dev/null", O_RDONLY) != 0)
- error("Can't open /dev/null");
- }
- }
- #endif
- --- 554,593 ----
- } else if (mode == FORK_BG) {
- ignoresig(SIGINT);
- ignoresig(SIGQUIT);
- ! if ((jp == NULL || jp->nprocs == 0)
- ! && ! fd0_redirected_p ()) {
- close(0);
- + #ifndef __MINT__
- if (open("/dev/null", O_RDONLY) != 0)
- error("Can't open /dev/null");
- + #else
- + if ((fd = open("/dev/null", O_RDONLY)) < 0)
- + error("Can't open /dev/null");
- + else {
- + dup2(fd, 0);
- + close(fd);
- + }
- + #endif
- }
- }
- #else
- if (mode == FORK_BG) {
- ignoresig(SIGINT);
- ignoresig(SIGQUIT);
- ! if ((jp == NULL || jp->nprocs == 0)
- ! && ! fd0_redirected_p ()) {
- close(0);
- + #ifndef __MINT__
- if (open("/dev/null", O_RDONLY) != 0)
- error("Can't open /dev/null");
- + #else
- + if ((fd = open("/dev/null", O_RDONLY)) < 0)
- + error("Can't open /dev/null");
- + else {
- + dup2(fd, 0);
- + close(fd);
- + }
- + #endif
- }
- }
- #endif
- diff --context --recursive --new-file bsd-sh/main.c sh03/main.c
- *** bsd-sh/main.c Fri Feb 19 08:44:22 1993
- --- sh03/main.c Mon Mar 22 21:10:02 1993
- ***************
- *** 65,70 ****
- --- 65,74 ----
- #include "init.h"
- #include "mystring.h"
-
- + #ifdef __MINT__
- + long _stksize = 20*1024L;
- + #endif
- +
- #define PROFILE 0
-
- int rootpid;
- ***************
- *** 146,157 ****
- --- 150,173 ----
- init();
- setstackmark(&smark);
- procargs(argc, argv);
- + #ifdef __MINT__
- + /* under MiNT, we are also a login shell if we've been started
- + * from the desktop with no arguments
- + * hohmuth 22 Mar 1993
- + */
- + if (!argv[0] || (!argv[0][0] && !argv[1]))
- + argv[0] = "-sh";
- + #endif
- if (argv[0] && argv[0][0] == '-') {
- state = 1;
- read_profile("/etc/profile");
- state1:
- state = 2;
- + #ifdef DOSFS
- + read_profile("profile.sh");
- + #else
- read_profile(".profile");
- + #endif
- } else if ((sflag || minusc) && (shinit = getenv("SHINIT")) != NULL) {
- state = 2;
- evalstring(shinit);
- diff --context --recursive --new-file bsd-sh/miscbltin.c sh03/miscbltin.c
- *** bsd-sh/miscbltin.c Fri Feb 19 08:44:44 1993
- --- sh03/miscbltin.c Sun Mar 21 15:03:18 1993
- ***************
- *** 99,105 ****
- --- 99,109 ----
- status = 1;
- break;
- }
- + #ifdef __MINT__
- + if (c == '\0' || c == '\r')
- + #else
- if (c == '\0')
- + #endif
- continue;
- if (backslash) {
- backslash = 0;
- diff --context --recursive --new-file bsd-sh/mkbuiltins sh03/mkbuiltins
- *** bsd-sh/mkbuiltins Fri Feb 19 08:44:48 1993
- --- sh03/mkbuiltins Wed Mar 10 08:33:22 1993
- ***************
- *** 41,47 ****
- if grep '^#define JOBS[ ]*1' shell.h > /dev/null
- then havejobs=1
- fi
- ! exec > obj/builtins.c
- cat <<\!
- /*
- * This file was generated by the mkbuiltins program.
- --- 41,47 ----
- if grep '^#define JOBS[ ]*1' shell.h > /dev/null
- then havejobs=1
- fi
- ! exec > builtins.c
- cat <<\!
- /*
- * This file was generated by the mkbuiltins program.
- ***************
- *** 66,72 ****
- echo ' NULL, 0
- };'
-
- ! exec > obj/builtins.h
- cat <<\!
- /*
- * This file was generated by the mkbuiltins program.
- --- 66,72 ----
- echo ' NULL, 0
- };'
-
- ! exec > builtins.h
- cat <<\!
- /*
- * This file was generated by the mkbuiltins program.
- diff --context --recursive --new-file bsd-sh/parser.c sh03/parser.c
- *** bsd-sh/parser.c Fri Feb 19 08:46:26 1993
- --- sh03/parser.c Sat May 22 00:44:22 1993
- ***************
- *** 99,105 ****
- STATIC union node *andor __P((void));
- STATIC union node *pipeline __P((void));
- STATIC union node *command __P((void));
- ! STATIC union node *simplecmd __P((void));
- STATIC void parsefname __P((void));
- STATIC void parseheredoc __P((void));
- STATIC int readtoken __P((void));
- --- 99,105 ----
- STATIC union node *andor __P((void));
- STATIC union node *pipeline __P((void));
- STATIC union node *command __P((void));
- ! STATIC union node *simplecmd __P((union node **, union node *));
- STATIC void parsefname __P((void));
- STATIC void parseheredoc __P((void));
- STATIC int readtoken __P((void));
- ***************
- *** 264,269 ****
- --- 264,279 ----
- int t;
-
- checkkwd = 2;
- + redir = 0;
- + rpp = &redir;
- + /* Check for redirection which may precede command */
- + while (readtoken() == TREDIR) {
- + *rpp = n2 = redirnode;
- + rpp = &n2->nfile.next;
- + parsefname();
- + }
- + tokpushback++;
- +
- switch (readtoken()) {
- case TIF:
- n1 = (union node *)stalloc(sizeof (struct nif));
- ***************
- *** 326,331 ****
- --- 336,345 ----
- }
- *app = NULL;
- n1->nfor.args = ap;
- + /* A newline or semicolon is required here to end
- + the list. */
- + if (lasttoken != TNL && lasttoken != TSEMI)
- + synexpect(-1);
- } else {
- #ifndef GDB_HACK
- static const char argvars[5] = {CTLVAR, VSNORMAL|VSQUOTE,
- ***************
- *** 337,345 ****
- n2->narg.backquote = NULL;
- n2->narg.next = NULL;
- n1->nfor.args = n2;
- }
- - if (lasttoken != TNL && lasttoken != TSEMI)
- - synexpect(-1);
- checkkwd = 2;
- if ((t = readtoken()) == TDO)
- t = TDONE;
- --- 351,361 ----
- n2->narg.backquote = NULL;
- n2->narg.next = NULL;
- n1->nfor.args = n2;
- + /* A newline or semicolon is optional here. Anything
- + else gets pushed back so we can read it again. */
- + if (lasttoken != TNL && lasttoken != TSEMI)
- + tokpushback++;
- }
- checkkwd = 2;
- if ((t = readtoken()) == TDO)
- t = TDONE;
- ***************
- *** 411,426 ****
- synexpect(TEND);
- checkkwd = 1;
- break;
- case TWORD:
- - case TREDIR:
- tokpushback++;
- ! return simplecmd();
- default:
- synexpect(-1);
- }
-
- /* Now check for redirection which may follow command */
- - rpp = &redir;
- while (readtoken() == TREDIR) {
- *rpp = n2 = redirnode;
- rpp = &n2->nfile.next;
- --- 427,442 ----
- synexpect(TEND);
- checkkwd = 1;
- break;
- + /* Handle an empty command like other simple commands. */
- + case TNL:
- case TWORD:
- tokpushback++;
- ! return simplecmd(rpp, redir);
- default:
- synexpect(-1);
- }
-
- /* Now check for redirection which may follow command */
- while (readtoken() == TREDIR) {
- *rpp = n2 = redirnode;
- rpp = &n2->nfile.next;
- ***************
- *** 442,455 ****
-
-
- STATIC union node *
- ! simplecmd() {
- union node *args, **app;
- ! union node *redir, **rpp;
- union node *n;
-
- args = NULL;
- app = &args;
- ! rpp = &redir;
- for (;;) {
- if (readtoken() == TWORD) {
- n = (union node *)stalloc(sizeof (struct narg));
- --- 458,481 ----
-
-
- STATIC union node *
- ! simplecmd(rpp, redir)
- ! union node **rpp, *redir;
- ! {
- union node *args, **app;
- ! union node **orig_rpp = rpp;
- union node *n;
-
- + /* If we don't have any redirections already, then we must reset
- + rpp to be the address of the local redir variable. */
- + if (redir == 0)
- + rpp = &redir;
- +
- args = NULL;
- app = &args;
- ! /* We save the incoming value, because we need this for shell
- ! functions. There can not be a redirect or an argument between
- ! the function name and the open parenthesis. */
- ! orig_rpp = rpp;
- for (;;) {
- if (readtoken() == TWORD) {
- n = (union node *)stalloc(sizeof (struct narg));
- ***************
- *** 463,469 ****
- rpp = &n->nfile.next;
- parsefname(); /* read name of redirection file */
- } else if (lasttoken == TLP && app == &args->narg.next
- ! && rpp == &redir) {
- /* We have a function */
- if (readtoken() != TRP)
- synexpect(TRP);
- --- 489,495 ----
- rpp = &n->nfile.next;
- parsefname(); /* read name of redirection file */
- } else if (lasttoken == TLP && app == &args->narg.next
- ! && rpp == orig_rpp) {
- /* We have a function */
- if (readtoken() != TRP)
- synexpect(TRP);
- ***************
- *** 836,847 ****
- }
- break;
- case CBQUOTE: /* '`' */
- - if (parsebackquote && syntax == BASESYNTAX) {
- - if (out == stackblock())
- - return lasttoken = TENDBQUOTE;
- - else
- - goto endword; /* exit outer loop */
- - }
- PARSEBACKQOLD();
- break;
- case CEOF:
- --- 862,867 ----
- ***************
- *** 855,861 ****
- }
- }
- endword:
- ! if (syntax != BASESYNTAX && eofmark == NULL)
- synerror("Unterminated quoted string");
- if (varnest != 0) {
- startlinno = plinno;
- --- 875,881 ----
- }
- }
- endword:
- ! if (syntax != BASESYNTAX && ! parsebackquote && eofmark == NULL)
- synerror("Unterminated quoted string");
- if (varnest != 0) {
- startlinno = plinno;
- ***************
- *** 1048,1054 ****
- struct jmploc jmploc;
- struct jmploc *volatile savehandler;
- int savelen;
- - int t;
-
- savepbq = parsebackquote;
- if (setjmp(jmploc.loc)) {
- --- 1068,1073 ----
- ***************
- *** 1068,1073 ****
- --- 1087,1119 ----
- savehandler = handler;
- handler = &jmploc;
- INTON;
- + if (oldstyle) {
- + /* We must read until the closing backquote, giving special
- + treatment to some slashes, and then push the string and
- + reread it as input, interpreting it normally. */
- + register char *out;
- + register c;
- + int savelen;
- + char *str;
- +
- + STARTSTACKSTR(out);
- + while ((c = pgetc ()) != '`') {
- + if (c == '\\') {
- + c = pgetc ();
- + if (c != '\\' && c != '`' && c != '$'
- + && (!dblquote || c != '"'))
- + STPUTC('\\', out);
- + }
- + STPUTC(c, out);
- + }
- + STPUTC('\0', out);
- + savelen = out - stackblock();
- + if (savelen > 0) {
- + str = ckmalloc(savelen);
- + bcopy(stackblock(), str, savelen);
- + }
- + setinputstring(str, 1);
- + }
- nlpp = &bqlist;
- while (*nlpp)
- nlpp = &(*nlpp)->next;
- ***************
- *** 1075,1084 ****
- (*nlpp)->next = NULL;
- parsebackquote = oldstyle;
- n = list(0);
- ! t = oldstyle? TENDBQUOTE : TRP;
- ! if (readtoken() != t)
- ! synexpect(t);
- (*nlpp)->n = n;
- while (stackblocksize() <= savelen)
- growstackblock();
- STARTSTACKSTR(out);
- --- 1121,1132 ----
- (*nlpp)->next = NULL;
- parsebackquote = oldstyle;
- n = list(0);
- ! if (!oldstyle && (readtoken() != TRP))
- ! synexpect(TRP);
- (*nlpp)->n = n;
- + /* Start reading from old file again. */
- + if (oldstyle)
- + popfile();
- while (stackblocksize() <= savelen)
- growstackblock();
- STARTSTACKSTR(out);
- diff --context --recursive --new-file bsd-sh/redir.c sh03/redir.c
- *** bsd-sh/redir.c Fri Feb 19 08:46:40 1993
- --- sh03/redir.c Sat May 22 00:44:30 1993
- ***************
- *** 68,73 ****
- --- 68,77 ----
-
- MKINIT struct redirtab *redirlist;
-
- + /* We keep track of whether or not fd0 has been redirected. This is for
- + background commands, where we want to redirect fd0 to /dev/null only
- + if it hasn't already been redirected. */
- + int fd0_redirected = 0;
-
- #ifdef __STDC__
- STATIC void openredirect(union node *, char *);
- ***************
- *** 122,127 ****
- --- 126,133 ----
- } else {
- close(fd);
- }
- + if (fd == 0)
- + fd0_redirected++;
- openredirect(n, memory);
- }
- if (memory[1])
- ***************
- *** 255,260 ****
- --- 261,268 ----
-
- for (i = 0 ; i < 10 ; i++) {
- if (rp->renamed[i] != EMPTY) {
- + if (i == 0)
- + fd0_redirected--;
- close(i);
- if (rp->renamed[i] >= 0) {
- copyfd(rp->renamed[i], i);
- ***************
- *** 348,350 ****
- --- 356,364 ----
- return newfd;
- #endif
- }
- +
- + /* Return true if fd 0 has already been redirected at least once. */
- + int
- + fd0_redirected_p () {
- + return fd0_redirected != 0;
- + }
- diff --context --recursive --new-file bsd-sh/redir.h sh03/redir.h
- *** bsd-sh/redir.h Fri Feb 19 08:46:44 1993
- --- sh03/redir.h Sat May 22 00:44:34 1993
- ***************
- *** 46,54 ****
- --- 46,56 ----
- void popredir(void);
- void clearredir(void);
- int copyfd(int, int);
- + int fd0_redirected_p(void);
- #else
- void redirect();
- void popredir();
- void clearredir();
- int copyfd();
- + int fd0_redirected_p();
- #endif
- diff --context --recursive --new-file bsd-sh/shell.h sh03/shell.h
- *** bsd-sh/shell.h Fri Feb 19 08:47:10 1993
- --- sh03/shell.h Sun Mar 14 07:10:46 1993
- ***************
- *** 57,66 ****
- #define JOBS 1
- #define SYMLINKS 1
- #define DIRENT 1
- ! #define UDIR 0
- #define ATTY 0
- #define BSD
- ! #define DEBUG 1
-
- #ifdef __STDC__
- typedef void *pointer;
- --- 57,66 ----
- #define JOBS 1
- #define SYMLINKS 1
- #define DIRENT 1
- ! #define UDIR 1
- #define ATTY 0
- #define BSD
- ! #define DEBUG 0
-
- #ifdef __STDC__
- typedef void *pointer;
- diff --context --recursive --new-file bsd-sh/sys/cdefs.h sh03/sys/cdefs.h
- *** bsd-sh/sys/cdefs.h
- --- sh03/sys/cdefs.h Tue Feb 16 00:00:00 1993
- ***************
- *** 0 ****
- --- 1,15 ----
- + #ifndef cdefs_h
- + #define cdefs_h
- + #include <stddef.h>
- + #include <sys/types.h>
- + #include <signal.h>
- +
- + typedef void *sig_t;
- +
- + #ifdef __STDC__
- + # define __P(x) x
- + #else
- + # define __P(x) ()
- + #endif
- +
- + #endif
- diff --context --recursive --new-file bsd-sh/var.c sh03/var.c
- *** bsd-sh/var.c Fri Feb 19 08:48:00 1993
- --- sh03/var.c Wed Feb 17 07:12:18 1993
- ***************
- *** 81,87 ****
- struct var vterm;
- #endif
-
- ! const struct varinit varinit[] = {
- #if ATTY
- {&vatty, VSTRFIXED|VTEXTFIXED|VUNSET, "ATTY="},
- #endif
- --- 81,90 ----
- struct var vterm;
- #endif
-
- ! #ifndef __MBASE__
- ! const
- ! #endif
- ! struct varinit varinit[] = {
- #if ATTY
- {&vatty, VSTRFIXED|VTEXTFIXED|VUNSET, "ATTY="},
- #endif
-